package com.base.commonlib.http.request;

import com.base.commonlib.http.RetrofitInitial;
import com.base.commonlib.http.call.DataRequestCall;
import com.base.commonlib.http.call.DataSynRequestCall;
import com.base.commonlib.http.service.PostService_Content;
import com.base.commonlib.http.service.PutService_Form;

import java.util.Map;

import okhttp3.RequestBody;

/**
 * Date：2019/3/29 下午6:08
 * Creator：arvin
 * Des：
 */

public class PutContentRequest extends BaseRequest<PutService_Form,DataRequestCall,DataSynRequestCall> {

    protected Map<String, RequestBody> content;

    public PutContentRequest(String method, Class<PutService_Form> service, Map<String, RequestBody> content, Map<String, String> headers, String baseUrl) {
        super(method, service, headers, baseUrl);
        this.content=content;
    }




    @Override
    public DataRequestCall build() {
        PutService_Form serviceIml = RetrofitInitial.getInstance().create(service);
        if(headers==null||headers.isEmpty())
        {
            return new DataRequestCall(serviceIml.upContent(baseUrl+method,content));
        }else
        {
            return new DataRequestCall(serviceIml.upContent(baseUrl+method,content,headers));
        }
    }

    @Override
    public DataSynRequestCall synBuild() {
        PutService_Form serviceIml = RetrofitInitial.getInstance().create(service);
        if(headers==null||headers.isEmpty())
        {
            return new DataSynRequestCall(serviceIml.synUpForm(baseUrl+method,  content));
        }else
        {
            return new DataSynRequestCall(serviceIml.synUpForm(baseUrl+method, content,headers));
        }
    }
}
